package com.tudouji.project.customer.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.customer.domain.Customerdepartgroup;
import com.tudouji.project.customer.service.ICustomerdepartgroupService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 部门客户关联Controller
 * 
 * @author tudouji
 * @date 2022-05-18
 */
@RestController
@RequestMapping("/customer/customerdepartgroup")
public class CustomerdepartgroupController extends BaseController
{
    @Autowired
    private ICustomerdepartgroupService customerdepartgroupService;

    /**
     * 查询部门客户关联列表
     */
    @PreAuthorize("@ss.hasPermi('customer:customerdepartgroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(Customerdepartgroup customerdepartgroup)
    {
        startPage();
        List<Customerdepartgroup> list = customerdepartgroupService.selectCustomerdepartgroupList(customerdepartgroup);
        return getDataTable(list);
    }

    /**
     * 导出部门客户关联列表
     */
    @PreAuthorize("@ss.hasPermi('customer:customerdepartgroup:export')")
    @Log(title = "部门客户关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Customerdepartgroup customerdepartgroup)
    {
        List<Customerdepartgroup> list = customerdepartgroupService.selectCustomerdepartgroupList(customerdepartgroup);
        ExcelUtil<Customerdepartgroup> util = new ExcelUtil<Customerdepartgroup>(Customerdepartgroup.class);
        return util.exportExcel(list, "customerdepartgroup");
    }

    /**
     * 获取部门客户关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:customerdepartgroup:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(customerdepartgroupService.selectCustomerdepartgroupById(guid));
    }

    /**
     * 新增部门客户关联
     */
    @PreAuthorize("@ss.hasPermi('customer:customerdepartgroup:add')")
    @Log(title = "部门客户关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Customerdepartgroup customerdepartgroup)
    {
        return toAjax(customerdepartgroupService.insertCustomerdepartgroup(customerdepartgroup));
    }

    /**
     * 修改部门客户关联
     */
    @PreAuthorize("@ss.hasPermi('customer:customerdepartgroup:edit')")
    @Log(title = "部门客户关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Customerdepartgroup customerdepartgroup)
    {
        return toAjax(customerdepartgroupService.updateCustomerdepartgroup(customerdepartgroup));
    }

    /**
     * 删除部门客户关联
     */
    @PreAuthorize("@ss.hasPermi('customer:customerdepartgroup:remove')")
    @Log(title = "部门客户关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(customerdepartgroupService.deleteCustomerdepartgroupByIds(guids));
    }
}
